﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ChuanYe.CountyFireManagement.Api.Models;
using ChuanYe.CountyFireManagement.BLL;
using ChuanYe.CountyFireManagement.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ChuanYe.CountyFireManagement.Api.Controllers
{
    /// <summary>
    /// 火灾过期信息
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FireExpireController : ControllerBase
    {
        /// <summary>
        /// 获取已超时的火灾ID
        /// </summary>
        /// <param name="obj">obj.FireID</param>
        /// <returns></returns>
        [HttpPost]
        public ResultDto<dynamic> GetUnExpire(UnFireExpireRequest obj)
        {
            ResultDto<dynamic> result = new ResultDto<dynamic>();
            try
            {
                result.FirstParam = FireExpireBLL.Instance.GetUnExpire(obj.FireId);
            }
            catch (Exception ex)
            {
                result.Status = 500;
                result.Message = "/FireExpire/GetUnExpire Server Error";
                LogHelper.Error(result.Message,ex);
            }
            return result;
        }

        /// <summary>
        /// 获取火灾最新一条的待超时记录
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultDto<dynamic> GetExpire(UnFireExpireRequest obj)
        {
            ResultDto<dynamic> result = new ResultDto<dynamic>();
            try
            {
                result.FirstParam = FireExpireBLL.Instance.GetExpire(obj.FireId);
            }
            catch (Exception ex)
            {
                result.Status = 500;
                result.Message = "/FireExpire/GetExpire Server Error";
                LogHelper.Error(result.Message,ex);
            }
            return result;
        }

    }
}